package com.x.rocketmq.entity;

import java.io.Serializable;
import java.util.List;

public class MessageDestination implements Serializable {

	private static final long serialVersionUID = 7466823702281811478L;

	private long clusterId;

	private long topicId;

	private String code;

	private boolean split;

	//type 0-代表按tag拆分 1-代表按表达式拆分
	private int splitType;
	//拆分规则
	private String splitValue;
	//是否保存DB（目前支持mongodb）
	private boolean db ;

	private boolean available;

	private boolean deleted;
	
	private List<MessageDestination> subList;

	public long getClusterId() {
		return clusterId;
	}

	public void setClusterId(long clusterId) {
		this.clusterId = clusterId;
	}

	public long getTopicId() {
		return topicId;
	}

	public void setTopicId(long topicId) {
		this.topicId = topicId;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public boolean isSplit() {
		return split;
	}

	public void setSplit(boolean split) {
		this.split = split;
	}

	public String getSplitValue() {
		return splitValue;
	}

	public void setSplitValue(String splitValue) {
		this.splitValue = splitValue;
	}

	public int getSplitType() {
		return splitType;
	}

	public void setSplitType(int splitType) {
		this.splitType = splitType;
	}

	public boolean isAvailable() {
		return available;
	}

	public void setAvailable(boolean available) {
		this.available = available;
	}

	public boolean isDeleted() {
		return deleted;
	}

	public void setDeleted(boolean deleted) {
		this.deleted = deleted;
	}
	
	public boolean getDb()
	{
		return db;
	}

	
	public void setDb(boolean db)
	{
		this.db = db;
	}
	
	public List<MessageDestination> getSubList()
	{
		return subList;
	}

	
	public void setSubList(List<MessageDestination> subList)
	{
		this.subList = subList;
	}

	
	
	@Override
	public int hashCode()
	{
		final int prime = 31;
		int result = 1;
		result = prime * result + (available ? 1231 : 1237);
		result = prime * result + (int) (clusterId ^ (clusterId >>> 32));
		result = prime * result + ((code == null) ? 0 : code.hashCode());
		result = prime * result + (db ? 1231 : 1237);
		result = prime * result + (deleted ? 1231 : 1237);
		result = prime * result + (split ? 1231 : 1237);
		result = prime * result + splitType;
		result = prime * result + ((splitValue == null) ? 0 : splitValue.hashCode());
		result = prime * result + ((subList == null) ? 0 : subList.hashCode());
		result = prime * result + (int) (topicId ^ (topicId >>> 32));
		return result;
	}

	@Override
	public boolean equals(Object obj)
	{
    if (this == obj) {
      return true;
    }
    if (obj == null) {
      return false;
    }
    if (getClass() != obj.getClass()) {
      return false;
    }
		MessageDestination other = (MessageDestination) obj;
    if (available != other.available) {
      return false;
    }
    if (clusterId != other.clusterId) {
      return false;
    }
		if (code == null)
		{
      if (other.code != null) {
        return false;
      }
		}
		else if (!code.equals(other.code)) {
      return false;
    }
    if (db != other.db) {
      return false;
    }
    if (deleted != other.deleted) {
      return false;
    }
    if (split != other.split) {
      return false;
    }
    if (splitType != other.splitType) {
      return false;
    }
		if (splitValue == null)
		{
      if (other.splitValue != null) {
        return false;
      }
		}
		else if (!splitValue.equals(other.splitValue)) {
      return false;
    }
		if (subList == null)
		{
      if (other.subList != null) {
        return false;
      }
		}
		else if (!subList.equals(other.subList)) {
      return false;
    }
    if (topicId != other.topicId) {
      return false;
    }
		return true;
	}

	public MessageDestination()
	{
		super();
	}

	public MessageDestination(long clusterId, long topicId, String code, boolean split, int splitType, String splitValue, boolean db, boolean available, boolean deleted,
			List<MessageDestination> subList)
	{
		super();
		this.clusterId = clusterId;
		this.topicId = topicId;
		this.code = code;
		this.split = split;
		this.splitType = splitType;
		this.splitValue = splitValue;
		this.db = db;
		this.available = available;
		this.deleted = deleted;
		this.subList = subList;
	}

	@Override
	public String toString()
	{
		return "MessageDestination [clusterId=" + clusterId + ", topicId=" + topicId + ", code=" + code + ", split=" + split + ", splitType=" + splitType + ", splitValue=" + splitValue + ", db=" + db
				+ ", available=" + available + ", deleted=" + deleted + ", subList=" + subList + "]";
	}

	

	
}
